<template>
  <div class="detail">
    <header>
      <div class="returns" @click="goBack()">
        <i class="iconfont icon-fanhui"></i>
      </div>
      <img class="img" src="../../public/images/底部.jpg" alt="" />
    </header>
    <section>

      <div class="goods">
        <img :src="goods.imgUrl" alt="" />
        <p class="price">￥ {{ goods.price }}</p>
        <p class="yunfei">运费： 退货免运费</p>
        <p class="name">
          {{ goods.name }}
        </p>
      </div>

      <div class="fangxingou" @click="fangxingou()">
        <van-icon class="thumb-circle" name="thumb-circle" />
        <p>放心购</p>
        <div class="tar">品质保证 合作商直销 免费上门退取 专属客服</div>
        <van-icon class="arrow" name="arrow" />
        <div class="tar2">
          <van-action-sheet v-model="show" title="放心购">
            <div class="content">
              <van-icon class="sign" name="sign" />
              <div class="p1">品质保证</div>
              <div class="p2">
                商家已通过 “国家企业信息公示系统”
                核验，许可资质齐全，商品品质有保证
              </div>

              <van-icon class="cash-on-deliver" name="cash-on-deliver" />
              <div class="p3">退货包运费</div>
              <div class="p4">
                商家提供退货包运费补贴，退换货成功后可补贴一定金额运费，实际赠送情况以订单详情页为准
              </div>

              <van-icon class="smile-comment-o" name="smile-comment-o" />
              <div class="p5">专属客服</div>
              <div class="p6">
                点击订单详情页-放系你够客服，快速解决售后问题。
              </div>

              <van-icon class="vip-card-o" name="vip-card-o" />
              <div class="p7">先行赔付</div>
              <div class="p8">
                若发生商品为过期/三无产品，商品秒数与书屋不符，与商家运费发生争议，消费者在15天内发起申请并提供有效凭证，可享受先行赔付
              </div>
            </div>
          </van-action-sheet>
        </div>
      </div>

      <div class="zhanshi">
        <p>产品展示</p>
        <van-icon class="upgrade" name="upgrade" />
      </div>
      <div class="main">
        <img :src="goods.imgDetail" alt="" />
      </div>

      <div class="shuoming">
        <van-collapse v-model="activeNames">
          <van-collapse-item name="1">
            <template #title>
              <div>商品说明 <van-icon name="question-o" /></div>
            </template>
            生产日期：2022年07月16日 至
            2022年07月16日品牌：万人茗系列：牛栏坑肉桂500g
            乌龙茶干茶形状：扭曲产地：中国大陆省份：福建省
            城市：武夷山市口味：醇香味包装种类：罐装
            是否为有机食品：否包装方式：袋装是否进口：国产
            套餐份量：5人套餐周期：1个月配送频次：1周1次<br />
            口感：醇厚甘爽价格段：500元以上茶种类：大红袍
            级别：特级生长季节：春季适用场景：下午茶 适用人群：通用 女性 男性
            中老年 白领净含量：500g包装规格：2罐
            储存条件：常温单件净含量：250g冲泡水温：100-100℃<br />
            采摘原料：一芽多叶适用茶具：盖碗 紫砂壶茶水比：1∶50
            茶香：果香首次冲泡时长：5秒生产许可证编号：SC11435078207275
            产品标准号：GB/T18745厂名：武夷山市龙鸣茶厂厂址：武夷山市武夷溪洲村下溪洲79号
            厂家联系方式：16505996888配料表：武夷岩茶储藏方法：密封、避光、防潮、防异味
            保质期：1080食品添加剂：无
          </van-collapse-item>
        </van-collapse>
      </div>

      <div class="more"></div>
    </section>
    <footer>
      <van-goods-action>
        <van-goods-action-icon icon="chat-o" text="客服" @click="showPopup()" />
        <van-popup v-model="show2">
          <p class="erweima">有问题请扫描二维码</p>
          <p class="liuyan">在平台留言即可</p>
          <img src="../../public/images/二维码.jpg" alt="" />
        </van-popup>
        <van-goods-action-icon
          icon="shop-o"
          text="购物车"
          @click="$router.push({ path: '/cart' })"
        />
        <van-goods-action-button
          color="#be99ff"
          type="warning"
          text="加入购物车"
          @click="addgoodsCart()"
        />
        <!-- <van-goods-action-button
          color="#7232dd"
          type="danger"
          text="立即购买"
          @click="payment()"
        /> -->
      </van-goods-action>
    </footer>
  </div>
</template>

<script>
import http from "@/common/api/request.js";
export default {
  data() {
    return {
      id: 0,
      goods: [],
      styleOption: {},
      BetterScroll: "",
      isShow: true,
      activeNames: ["1"],
      show: false,
      show2: false,
    };
  },

  created() {
    console.log(1);
    this.getData();
  },
  watch: {
    $route(to, from) {
      this.getData();
      if (this.$route.params.id) {
        this.getData();
      }
    },
  },

  methods: {
    async getData() {
      let res = await http.$axios({
        url: "http://127.0.0.1:3008/goods/goodsdetail/" + this.$route.params.id,
      });
      this.goods = res;
    },

    // 放心购
    fangxingou() {
      this.show = !this.show;
    },
    // 返回上一级
    goBack() {
      this.$router.go(-1);
    },

    // 气泡框
    showPopup() {
      this.show2 = true;
    },

    // 加入购物车
    addgoodsCart() {
      this.$http
        .post(
          "http://127.0.0.1:3008/goods/goodscart",
          {
            id: this.goods.id,
            imgUrl: this.goods.imgUrl,
            name: this.goods.name,
            price: this.goods.price,
            num: this.goods.num,
            // sum: this.goods.sum,
          },
          { emulateJSON: true }
        )
        .then(function (res) {});
      this.$toast({
        message: "加入购物车成功",
        forbidClick: true,
        duration: 1000,
      });
    },

    // 立即购买
    payment(){

    }

  },
};
</script>

<style scoped lang="scss">
.detail {
  background-color: #f3f3f3;
  font-family: STFangsong;
  letter-spacing: 1px;

  header {
    margin-top: 11px;

    i {
      font-family: "iconfont" !important;
      font-size: 75px;
      font-style: normal;
      z-index: 1;
      position: relative;
    }
    .img {
      vertical-align: middle;
      width: 100%;
      height: 169px;
      margin-top: -155px;
    }
  }

  section {
    margin-top: -41px;
    .goods {
      background-color: #fff;
      img {
        width: 100%;
      }
      .price {
        color: #fd3f31;
        margin-top: 21px;
        font-size: 26px;
        margin-left: 20px;
      }

      .yunfei {
        font-size: 15px;
        margin-top: -26px;
        margin-left: 237px;
        color: #939393;
      }
      .name {
        font-size: 18px;
        margin-left: 11px;
        margin-top: 18px;
        padding-bottom: 21px;
      }
    }

    .fangxingou {
      background-color: #fff;
      margin-top: 20px;
      .thumb-circle {
        position: relative;
        font-size: 27px;
        left: 20px;
        top: 8px;
        color: #00d947;
      }

      .arrow {
        position: relative;
        font-size: 25px;
        top: -56px;
        left: 343px;
      }
      .van-action-sheet__header {
        color: #00d947;
        font-size: 30px;
        margin-top: 20px;
        font-weight: 800;
      }
      .content {
        padding: 16px 16px 160px;
        .sign,
        .cash-on-deliver,
        .smile-comment-o,
        .vip-card-o {
          font-size: 20px;
          color: #00d947;
          left: 9px;

          top: 37px;
        }

        .p1,
        .p3,
        .p5,
        .p7,
        .p9 {
          font-size: 18px;
          margin-left: 39px;
        }

        .p2,
        .p4,
        .p6,
        .p8,
        .p10 {
          font-size: 14px;
          margin-left: 39px;
          margin-top: 8px;
          color: #a5a5a5;
        }

        // .p1 {
        // }
      }
      p {
        color: #00d947;
        font-size: 23px;
        padding-left: 20px;
        font-weight: 1000;
        padding-left: 54px;
        font-weight: 1000;
        margin-top: -34px;
      }
      .tar {
        font-size: 14px;
        margin-left: 18px;
        color: #7c7c7c;
        margin-top: 20px;
      }
    }

    .zhanshi {
      background-color: #ffffff;
      margin-top: 20px;

      p {
        padding-left: 106px;
        padding-top: 40px;
        font-weight: 900;
      }

      .upgrade {
        transform: rotate(180deg);
        margin-left: 158px;
        margin-top: 27px;
        font-size: 53px;
      }
    }
    .main {
      margin-top: 6px;
    }

    .shuoming {
      background-color: #ffffff;
      margin-top: 38px;
      padding: 18px;

      div {
        font-size: 17px;
      }
    }

    .more {
      padding-bottom: 150px;
    }
  }

  footer {
    .van-goods-action {
      height: 80px;
    }

    .erweima {
      font-size: 20px;
      text-align: center;
      margin-top: 20px;
    }
    .liuyan {
      font-size: 20px;
      text-align: center;
    }

    img {
      vertical-align: middle;
      height: 323px;
      width: 310px;
    }
  }
}
</style>
